# RedFire 行情数据服务 Docker镜像
# 基于Python 3.11官方镜像构建高性能行情数据微服务

FROM python:3.11-alpine

# 设置工作目录
WORKDIR /app

# 设置环境变量
ENV PYTHONDONTWRITEBYTECODE=1 \
    PYTHONUNBUFFERED=1 \
    PYTHONPATH=/app \
    PIP_NO_CACHE_DIR=1 \
    PIP_DISABLE_PIP_VERSION_CHECK=1

# 安装系统依赖
RUN apk add --no-cache \
    gcc \
    musl-dev \
    libffi-dev \
    openssl-dev \
    curl \
    wget \
    git \
    make \
    build-base \
    linux-headers

# 复制依赖文件
COPY services/market-data-service/requirements.txt .

# 安装Python依赖
RUN pip install --upgrade pip==24.0 && \
    pip install --no-cache-dir --disable-pip-version-check -r requirements.txt

# 复制应用代码
COPY services/market-data-service/app/ ./app/

# 创建必要的目录
RUN mkdir -p /app/logs /app/data /app/config

# 设置权限

# 健康检查
HEALTHCHECK --interval=30s --timeout=10s --start-period=30s --retries=3 \
    CMD curl -f http://localhost:8003/health || exit 1

# 暴露端口
EXPOSE 8003

# 启动命令
CMD ["python", "-m", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8003"]
